Repository navigation
fix(studio): a sealed resize follows the pointer instead of trailing it by about 6 px - #8537
Merged
Merged
Conversation
Contributor
Edit accuracy: accurate 271 (base branch 271), smooth 71 of thoseThe gate passes. Quarantined, measured but not gated (0) |
jrusso1020
approved these changes
Nov 22, 2026
jrusso1020
left a comment
Collaborator
There was a problem hiding this comment.
APPROVE at 60bd943d.
Need ✅ (sealed resize trailed the pointer by about 6 px) · Size ✅ (previewDrafts.ts only, plus tests) · Reuse ✅ (the existing per-frame queue and field merge) · Simpler ✅ · Structure ✅
Risk: low. Draws only, on sealed previews; an unsealed preview returns before queueing.
- Draws now leave in one
queueMicrotasksend per frame, which always runs before the next pointer event. Both resize draws (the offset, thendrawPreviewDraft({ size })) run in one handler, so the frame never gets an offset without its size. - Each end still sends at once, with any waiting draw ahead of it in the same message, and the frame applies drafts in order. That covers cancel and restore, commit ends, the keep-size end and
restoreRotationDraft. The later scheduled send finds nothing left and does nothing. takePreviewDraftEndssends a waiting draw first. Draws and the save both go throughpreviewAnswer→client.requestin call order, so the draw goes out before the save that carries its end (#8473).previewDraftLivestill reads the drawn-state map synchronously. Queues stay keyed by iframe, so two frames don't interfere, and a draw that lands after a reload is skipped as before.
Checked locally:
- At head:
previewDrafts.test.tspasses 16/16.src/components/editorplususeDomEditPositionPatchCommitpass 2187 tests (182 files). The sealed-preview tests pass 259/259. - With main's
previewDrafts.tsrestored, the two tests named on the "fails without the fix:" line fail. - With the flush in
takePreviewDraftEndsremoved, "sends a draw waiting in this task before a save that carries its end" fails. - CI is green at this head.
Non-blocking:
- The names and comments say "task end", but a microtask runs when the current call stack empties. Draws separated by an
await, or made in two separate listener callbacks, would not merge. No draw site does that today. - If a draw is already in flight when a save starts, the end is left out of the save, as on main. The existing waiting check handles it.
— Rames (hf-review)
This was referenced Nov 22, 2026
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
On a sealed preview, a resize now grows the element under the pointer. Before, on each pointer step the element stepped back a few pixels for a frame and then jumped about 6 px to catch up, so a resize trailed the pointer by about 6 px.
Why
A resize step draws two parts on the frame's element: its offset (
applyManualOffsetDragDraft) and its size (drawPreviewDraft({ size })), one call after the other inresizeDraft.ts.drawPreviewDraftsent straight away whenever no request was in flight. So the first call left on its own, carrying the step's new offset with the previous size, and the frame painted that half state. The size followed one round trip later. When a request was already in flight the two calls merged, which is why the trail came and went with load.The edit-accuracy bench shows it in every sealed resize. In
seqplainkeys-none-center-r0-root-z100at 4x CPU, every resize trailed the pointer by 6.2-6.3 px, with a 6.4 px jump. Unsealed, the same case trails 0.0 px. The bench's per-frame trace shows the corner stepping back about 2.5 px, then jumping +6.4 px to the pointer, on each step. The drop andrenderKeychecks failed whenever their reading caught that drawn offset.Related work
Refs #7846 (Studio's preview sealed by default): its edit-accuracy gate flags these cases. #8473 sends a save's draft end in the same message as the patch; this change keeps that working.
How
previewDrafts.tsalone changes:drawPreviewDraftschedules its send for the end of the current task, once per frame's queue, instead of sending at once. Everything a gesture draws in one step leaves as one draft. Fields merge as before: a later draw of the same field wins, and a field no later draw names keeps its value.takePreviewDraftEnds, which a save calls right before it sends, now sends any waiting draw first. The draw goes out before the save that carries its end, and the end can still ride the save (fix(studio): a sealed move or resize ends its draft in the save's own frame message #8473).Every draw site now batches this way:
manualOffsetDrag.ts);resizeDraft.ts);rotationDraft.ts);gestureUndoRevert.ts);previewDrafts.ts), where the offset clear and its end now share one message.A plain (unsealed) preview doesn't change: its elements have no stand-in, so
drawPreviewDraftreturns before queueing anything.No visible change
On a sealed preview, a resize follows the pointer without the small jump on each step. The interface itself doesn't change.
Test plan
fails without the fix:
packages/studio/src/components/editor/previewDrafts.test.ts:"sends a draw waiting in this task before a save that carries its end" passes on main and fails if the save's flush is removed.
"sends one request at a time and draws only the latest of the moves that waited" still holds. It now makes its first draw in a task of its own, because draws in one task leave together.
packages/studio/src/components/editor,src/hooksandsrc/player(578 files, 6,714 tests) passes on Linux. Three earlier runs each had one failure,runtimeProtocol.test.ts. It also failed on main's code in that tree and passes once the core package is rebuilt, so it came from a stale build, not this change.seqplainkeys-none-center-r0-root-z100, sealed: resizes trail 0.2-0.3 px, against 6.2-6.3 px before; unsealed is 0.0-0.1. Its drop andrenderKeychecks pass in all three runs. One run still misses a move step by 12.4 px and one misses its undo; both are separate work.resize-none-px-r0-root-z100, sealed: passes every check, tracking 0.23 px. Before, tracking and teleport failed in 3 of 3 runs.